use axum::response::IntoResponse;
use axum::{Json, Router};
use axum::routing::{get, post};
use tokio::net::TcpListener;

#[tokio::main]
async fn main() {
    println!("🌟 REST API Service 🌟");

    let app = Router::new()
      .route("/hello", get(hello));

    println!("✅ Server started successfully at 0.0.0.0:8080");

    let listener = TcpListener::bind("0.0.0.0:8080").await.unwrap();
    axum::serve(listener, app.into_make_service())
      .await
      .unwrap();
}

async fn hello() -> impl IntoResponse {
    const MESSAGE: &str = "API Services";

    let json_response = serde_json::json!({
        "status": "ok",
        "message": MESSAGE
    });

    Json(json_response)
}